//
//  CardTableViewCell.m
//  shanHaiHuiApp
//
//  Created by DS on 2018/3/12.
//  Copyright © 2018年 徐双. All rights reserved.
//

#import "CardTableViewCell.h"
@interface CardTableViewCell()

//批号
Strong UILabel * cardLabel;
Strong UILabel * cardDetailLabel;
//库存
Strong UILabel * kucunLabel;
Strong UILabel * kucunDetailLabel;
//到期日
Strong UILabel * dateLabel;
Strong UILabel * dateDetailLabel;
//数量
Strong UILabel * countLabel;
Strong UILabel * countDetailLabel;
//修改批次批号
Strong UIButton * changeCardBtn;

Strong UIView * lineView;

@end

@implementation CardTableViewCell

- (instancetype)initWithCellIdentifier:(NSString *)cellID{
    
    self = [super initWithCellIdentifier:cellID];
    
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        _cardLabel = [[UILabel alloc] init];
        _cardLabel.text = @"批号-批次";
        _cardLabel.textColor = getColor(textColor);
        _cardLabel.font = DEF_FontSize_11;
        
        _cardDetailLabel = [[UILabel alloc] init];
        _cardDetailLabel.text = @"456789999";
        _cardDetailLabel.textColor = getColor(textColor);
        _cardDetailLabel.font = DEF_FontSize_11;
        
        
        _kucunLabel = [[UILabel alloc] init];
        _kucunLabel.text = @"库存";
        _kucunLabel.textColor = getColor(textColor);
        _kucunLabel.font = DEF_FontSize_11;
        
        _kucunDetailLabel = [[UILabel alloc] init];
        _kucunDetailLabel.text = @"99";
        _kucunDetailLabel.textColor = getColor(textColor);
        _kucunDetailLabel.font = DEF_FontSize_11;
        
        _dateLabel = [[UILabel alloc] init];
        _dateLabel.text = @"到期日";
        _dateLabel.textColor = getColor(textColor);
        _dateLabel.font = DEF_FontSize_11;
        
        _dateDetailLabel = [[UILabel alloc] init];
        _dateDetailLabel.text = @"20190101";
        _dateDetailLabel.textColor = getColor(textColor);
        _dateDetailLabel.font = DEF_FontSize_11;
        
        _countLabel = [[UILabel alloc] init];
        _countLabel.text = @"数量";
        _countLabel.textColor = getColor(textColor);
        _countLabel.font = DEF_FontSize_11;
        
        _countDetailLabel = [[UILabel alloc] init];
        _countDetailLabel.text = @"10";
        _countDetailLabel.textColor = getColor(textColor);
        _countDetailLabel.font = DEF_FontSize_11;
        
        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor = getColor(dividerColor);
        
        [self sd_addSubviews:@[self.cardLabel,self.cardDetailLabel,self.kucunLabel,self.kucunDetailLabel,self.dateLabel,self.dateDetailLabel,self.countLabel,self.countDetailLabel,self.lineView]];
        
        [self layOutFrame];
        
        
    }
    return self;
}

- (void)layOutFrame{
    
    ws(self)
    
    [self.cardLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(UNIT_WIDTH(30));
        make.top.mas_equalTo(UNIT_HEIGHT(5));
        make.height.mas_equalTo(UNIT_HEIGHT(20));
    }];
    
    [self.cardDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(UNIT_WIDTH(-30));
        make.centerY.mas_equalTo(weakself.cardLabel.mas_centerY);
        make.height.mas_equalTo(UNIT_HEIGHT(20));
    }];
    
    [self.kucunLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(UNIT_WIDTH(30));
        make.top.mas_equalTo(weakself.cardLabel.mas_bottom).offset(UNIT_HEIGHT(9));
        make.height.mas_equalTo(UNIT_HEIGHT(20));
    }];
    
    [self.kucunDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(UNIT_WIDTH(-30));
        make.centerY.mas_equalTo(weakself.kucunLabel.mas_centerY);
        make.height.mas_equalTo(UNIT_HEIGHT(20));
    }];
    
    [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(UNIT_WIDTH(30));
        make.top.mas_equalTo(weakself.kucunLabel.mas_bottom).offset(UNIT_HEIGHT(9));
        make.height.mas_equalTo(UNIT_HEIGHT(20));
    }];
    
    [self.dateDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(UNIT_WIDTH(-30));
        make.centerY.mas_equalTo(weakself.dateLabel.mas_centerY);
        make.height.mas_equalTo(UNIT_HEIGHT(20));
    }];
    
    [self.countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(UNIT_WIDTH(30));
        make.top.mas_equalTo(weakself.dateLabel.mas_bottom).offset(UNIT_HEIGHT(9));
        make.height.mas_equalTo(UNIT_HEIGHT(20));
    }];
    [self.countDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(UNIT_WIDTH(-30));
        make.centerY.mas_equalTo(weakself.countLabel.mas_centerY);
        make.height.mas_equalTo(UNIT_HEIGHT(20));
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakself.countLabel.mas_bottom).offset(10);
        make.left.mas_equalTo(0);
        make.height.mas_equalTo(0.5);
        make.right.mas_equalTo(0);
    }];
  
}

- (void)setModel:(PayMentSpphModel *)model{
    
    _model = model;
    
    self.cardDetailLabel.text = [NSString stringWithFormat:@"%@-%@",model.fPh,model.fPc];
    self.kucunDetailLabel.text = [NSString stringWithFormat:@"%@",model.fSl];
    self.dateDetailLabel.text = [NSString stringWithFormat:@"%@",model.fDqdate];
    self.countDetailLabel.text = [NSString stringWithFormat:@"%@",model.xssl];
    
}


@end
